package food;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class food implements WritableComparable<food> {
    private String foodName;
    private int dicuss;
    private int papularition;

    public int compareTo(food o) {
        if (o.papularition - this.papularition == 0) {
            return o.dicuss - this.dicuss;
        }
        return o.papularition - this.papularition;
    }

    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(foodName);
        dataOutput.writeInt(dicuss);
        dataOutput.writeInt(papularition);
    }

    public void readFields(DataInput dataInput) throws IOException {
        foodName = dataInput.readUTF();
        dicuss = dataInput.readInt();
        papularition = dataInput.readInt();
    }

    public void set(String foodName, int dicuss, int papularition) {
        this.foodName = foodName;
        this.dicuss = dicuss;
        this.papularition = papularition;
    }

    public String getFoodName() {
        return foodName;
    }

    public void setFoodName(String foodName) {
        this.foodName = foodName;
    }

    public int getDicuss() {
        return dicuss;
    }

    public void setDicuss(int dicuss) {
        this.dicuss = dicuss;
    }

    public int getPapularition() {
        return papularition;
    }

    public void setPapularition(int papularition) {
        this.papularition = papularition;
    }


    @Override
    public String toString() {
        return foodName+","+dicuss+","+papularition;
    }
}
